package com.fzkj.shejimoshi.obverse;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 被观察者
 */
public class Publisher {

    List<Obverse> obverses = new ArrayList<>();

    void add(Obverse obvserse){
        obverses.add(obvserse);
        System.out.println("添加观察者成功");
    }

    void remove(Obverse o){
        obverses.remove(o);
        System.out.println("删除观察者成功");
    }

    void notifyObv(String msg){
        for (Obverse ob:obverses) {
            ob.update(msg);
        }
    }

    void notify1(Map<String, Object> maps){
        for (Obverse ob:obverses) {
            ob.update(maps.get("title")+"的主要内容有："+maps.get("msg"));
        }
    }


}
